package com.ruiyian.netty.DataUtils;


import com.aliyun.outboundbot20191226.models.AssignJobsResponse;
import com.aliyun.tea.TeaException;

public class Sample {

    /**
     * 使用AK&SK初始化账号Client
     * @param accessKeyId
     * @param accessKeySecret
     * @return Client
     * @throws Exception
     */
    public static com.aliyun.outboundbot20191226.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
            // 必填，您的 AccessKey ID
            .setAccessKeyId(accessKeyId)
            // 必填，您的 AccessKey Secret
            .setAccessKeySecret(accessKeySecret);
        // Endpoint 请参考 https://api.aliyun.com/product/OutboundBot
        config.endpoint = "outboundbot.cn-shanghai.aliyuncs.com";
        return new com.aliyun.outboundbot20191226.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        // 请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID 和 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
        // 工程代码泄露可能会导致 AccessKey 泄露，并威胁账号下所有资源的安全性。以下代码示例使用环境变量获取 AccessKey 的方式进行调用，仅供参考，建议使用更安全的 STS 方式，更多鉴权访问方式请参见：https://help.aliyun.com/document_detail/378657.html
        com.aliyun.outboundbot20191226.Client client = Sample.createClient("LTAI5t8hHXoMHNqvedtxd4To", "m7NdrqX2Kq53rBFduGQHWsYVhSFKRx");
        com.aliyun.outboundbot20191226.models.AssignJobsRequest assignJobsRequest = new com.aliyun.outboundbot20191226.models.AssignJobsRequest()
            .setJobGroupId("f2b85d27-5d17-4464-abae-32e7b1aa4d2f")
            .setInstanceId("5e961eee-accf-458c-83a4-8fae27d7d790")
            .setJobsJson(java.util.Arrays.asList("{\n" +
                "    \"extras\":[\n" +
                "        {\n" +
                "            \"value\":\"对面山隧道\",\n" +
                "            \"key\":\"tunnelName\"\n" +
                "        },\n" +
                "        {\n" +
                "            \"value\":\"k150+400\",\n" +
                "            \"key\":\"stakeMark\"\n" +
                "        },\n" +
                "        {\n" +
                "            \"value\":\"消防水带\",\n" +
                "            \"key\":\"devName\"\n" +
                "        },\n" +
                "        {\n" +
                "            \"value\":\"脱落\",\n" +
                "            \"key\":\"status\"\n" +
                "        }\n" +
                "    ],\n" +
                "    \"contacts\":[\n" +
                "        {\n" +
                "            \"phoneNumber\":\"15924039803\",\n" +
                "            \"name\":\"张三\",\n" +
                "            \"referenceId\":\"2c9a9a7c6caedab6016cb1ddd13325ed\",\n" +
                "            \"honorific\":\"张先生\"\n" +
                "        }\n" +
                "    ]\n" +
                "}"));
    com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
        // 复制代码运行请自行打印 API 的返回值
        AssignJobsResponse response = client.assignJobsWithOptions(assignJobsRequest, runtime);
            System.out.println(response.body.code);
    } catch (TeaException error) {
        // 错误 message
        System.out.println(error.getMessage());
        // 诊断地址
        System.out.println(error.getData().get("Recommend"));
        com.aliyun.teautil.Common.assertAsString(error.message);
    } catch (Exception _error) {
        TeaException error = new TeaException(_error.getMessage(), _error);
        // 错误 message
        System.out.println(error.getMessage());
        // 诊断地址
        System.out.println(error.getData().get("Recommend"));
        com.aliyun.teautil.Common.assertAsString(error.message);
    }
}
}
